import React, { Component } from "react";
import { Table, Button } from "antd";
import axios from "axios";
class ViewAnswers extends Component {
  constructor(props) {
    super(props);
    // 设置 initial state
    this.state = {
        answers:[]
    };
  }
   componentDidMount() {
    var _this = this;
    axios
      .get("http://localhost:7952/api/Questionnaire/GetAllAnswer")
      .then(function(response) {
        _this.setState({ answers: response.data });
      })
      .catch(function(error) {
        console.log(error);
      });
  }
  render() {
    const columns = [
      {
        title: "答案编号",
        dataIndex: "AnswerId",
        key: "AnswerId",
        render: text => <a href={"http://localhost:8080/#/AnswerDetails/"+text}>{text}</a>
      },
       {
        title: "问卷名称",
        dataIndex: "QuestionnaireTitle",
        key: "AnswerId"+1
      },
      {
        title: "IP地址",
        dataIndex: "IpAddress",
        key: "IpAddress"
      },
      {
        title: "填写时间",
        dataIndex: "CreateTime",
        key: "CreateTime"
      }
    ];
    return (
      <div className="content-wrapper">
        <section
          className="content"
          style={{
            minHeight: 650
          }}
        >
          <div>
            <section className="content-header">
              <h1>
                查看答案
                <small>答案概览</small>
              </h1>
              <ol className="breadcrumb">
                <li>
                  <a href="#">
                    <i className="fa fa-dashboard" />
                    Stage
                  </a>
                </li>
                <li>
                  <a href="#">后台管理</a>
                </li>
                <li className="active">查看答案</li>
              </ol>
            </section>
            <br />
            <div
              className="box"
              style={{
                minHeight: 530
              }}
            >
              <div className="box-header with-border">
                <h3 className="box-title">新增问卷</h3>
                <div className="box-tools pull-right">
                  <span className="label label-primary">概览</span>
                </div>
              </div>
              <div className="box-body">
                <div>
                  <Table
                   rowKey="AnswerId"
                    columns={columns}
                    dataSource={this.state.answers}
                  />
                </div>
              </div>
              <div className="box-footer" />
            </div>
          </div>
        </section>
      </div>
    );
  }
}
export default ViewAnswers;
